package com.ruoyi.web.controller.kpl;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.stock.domain.StockInfo;
import com.ruoyi.stock.domain.StockSector;
import com.ruoyi.stock.service.IStockInfoService;
import com.ruoyi.stock.service.IStockSectorService;
import com.ruoyi.stock.domain.query.StockSectorQuery;
import com.ruoyi.stock.service.impl.test.LonghuDataProcessor;
import com.ruoyi.stock.service.impl.test.LonghuResponse;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/kpl")
public class KplController extends BaseController
{
    @Autowired
    private IStockSectorService iStockSectorService;
    @Autowired
    private IStockInfoService iStockInfoService;


    private String prefix = "kpl";

    @GetMapping("/index")
    public String index()
    {
        return prefix + "/index";
    }

    /**
     * 获取板块列表
     * @param stockSectorQuery
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo getStockSector(StockSectorQuery stockSectorQuery)
    {
        startPage();
        List<StockSector> list = iStockSectorService.getStockSector(stockSectorQuery);
        return getDataTable(list);
    }

    /**
     * 获取股票池列表
     * @param stockSectorQuery
     * @return
     */
    @PostMapping("/getStockInfo")
    @ResponseBody
    public TableDataInfo getStockInfo(StockSectorQuery stockSectorQuery)
    {
        startPage();
        List<StockInfo> list = iStockInfoService.getStockInfo(stockSectorQuery);
        return getDataTable(list);
    }
}